package com.usian.controller;

import com.usian.utils.FastDFSClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class FileController {
    @Autowired
    private FastDFSClientUtil fastDFSClientUtil;
    @RequestMapping("upload")
    public String upload(MultipartFile file){
        String s = null;
        try {
            s = fastDFSClientUtil.uploadFile(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }
    @RequestMapping("del")
    public String del(String filePath){
        try {
            fastDFSClientUtil.delFile(filePath);
            return "删除成功！";
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "删除失败！";
    }
}
